//
//  LSSortTableView.m
//  LibraryStorm
//
//  Created by Enel@Lightning on 4/10/14.
//  Copyright (c) 2014 3ATeam. All rights reserved.
//

#import "LSSortTableView.h"

@interface LSSortTableView ()

@end
@implementation LSSortTableView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

#pragma mark - Table view datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.items.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"SortCell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.textLabel.font = Roboto_Regular(14);
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    if (indexPath.row <= self.items.count) {
        if (indexPath.row == self.selectedIndex) {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
        }
        NSString *sortType = [self.items objectAtIndex:indexPath.row];
        cell.textLabel.text = sortType;
    }
    
    return cell;
}

@end
